﻿using ApiPlugin;
using ApiPlugin.Plugin;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class DynamicPluginExtensions
    {
        /// <summary>
        /// controller动态插件开发；请调用IPluginService实现
        /// </summary>
        public static IServiceCollection AddDynamicControllerPlugin(this IServiceCollection services)
        {
            services.AddSingleton(sp => CustomActionDescriptorChangeProvider.Instance);
            services.AddSingleton<IActionDescriptorChangeProvider>(sp => CustomActionDescriptorChangeProvider.Instance);
            services.AddSingleton<IPluginService, PluginService>();

            return services;
        }
    }
}
